import { onActivated, onMounted } from 'vue'

export default function useFlush(key: string, onFlush: () => void) {
  const flush = () => {
    if (!window.flags[key]) return
    window.flags[key] = false
    onFlush()
  }

  onMounted(flush)
  onActivated(flush)
}
